package sjd.ahsj.springbootmybatisplusoracle.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import sjd.ahsj.springbootmybatisplusoracle.entity.BaseUser;
import com.baomidou.mybatisplus.mapper.BaseMapper;

/**
 * <p>
 * 会员 Mapper 接口
 * </p>
 *
 * @author zhanghaogao
 * @since 2018-09-18
 */
public interface BaseUserMapper extends BaseMapper<BaseUser> {


    /**
     * 扣除余额
     *
     * @param userId
     * @param amount
     * @return
     */
    @Update("update base_user set gold=gold-#{amount} where id=#{userId} and gold>=#{amount}")
    int deductionsAmount(@Param("userId") Long userId, @Param("amount") Long amount);


    /**
     * 增加余额
     *
     * @param userId
     * @param amount
     * @return
     */
    @Update("update base_user set gold=gold+#{amount} where id =#{userId}")
    int addAmount(@Param("userId") Long userId, @Param("amount") Long amount);

}
